$(function(){
	
	$.ajax({
		   	type:"get",
		   	url:"../json/user.json",
		   	async:true,
		   	//dataType:"jsonp",
		   
		   	success:function(data){
		   		console.log(data);
		   		$.each(data, function(i,n) {
		   			  admin =   n.admin ;
		   			  pas = n.pas;
		   		});
		   		
		   		$("#but").click(function(){
		   			 val = $("#ipt").val();
		   			 valone = $("#iptone").val();
		   			 
		   			    		$.ajax({
			url: 'http://172.16.24.201:8080/login',
			type: 'post',
			//dataType: 'jsonp',
			data: {"param1": val,
			         "pas":valone


		},
			success:function(data){
                 console.log(data)
			}
		})		 
		   			if (val==admin&&valone==pas){
		   				alert("登陆成功");
		   				location.href = "numbertwo.html"
		   			}else{
		   				alert("账号或者密码错误")
		   				//console.log(admin,pas)
		   			}
		   		})
		   	}
		   });
	
	function fun(){
		$('#ampleModal').modal('show');

		var verifyCode = new GVerify("v_container");
		$('body').on('keydown','#recipient-name',function(e){
						
				// alert($(e.target))
				var val = $(this).val().trim()
				if(val){
					$(this).siblings('.phoneNumber').hide()
				}else{
					$(this).siblings('.phoneNumber').show()
				}
			})


	$('#nextStep').click(function(){
			var inp = $('#recipient-name').val();
//			if(!/^1\d{10}$/.test(inp)) return $('#recipient-name').val('请输入正确的手机号').css('color','red')
			var res = verifyCode.validate(document.getElementById("code_input").value);
//			if(!res) return $('#code_input').val('验证码错误').css('color','red')
			

			$('#leModal').modal('show');
			$('#ampleModal').modal('hide');
			$('#getVerification span').text(inp);
			var num = 60;
			var ss = setInterval(function(){
				num --
				$('#countDown span').text(num);
				if(num === 0){
					clearInterval(ss)
				}
			},1000)

			$('#nextStep1').click(function(){
				if($('#testGetCode').val() != ''){
					$('#ampleModal1').modal('show')
					$('#leModal').modal('hide');
					
					
					$('#nextStep2').click(function(){
						var aa = $('#recipient-name2').val().trim();
						var bb = $('#recipient-name3').val().trim();
						var cc = $('#recipient-name1').val();
						if(cc.length <= 4){
							alert('昵称不符')
						}else if(aa != bb || aa == '' || bb == ''){
							alert('密码错误')
						}else{
							$('#ampleModal1').modal('hide')
						}
					})
				}else{
					alert("验证码错误")
				}
			})
		})
	}
	
	$('#passwordRetrieval').click(function(){
		fun()
	})
	
	$('.newUser').click(function(){
		fun()
	})

	$('.QQLogin').click(function(){
		location.href = 'https://graph.qq.com/oauth/show?which=Login&display=pc&response_type=code&client_id=101109290&redirect_uri=http%3A%2F%2Fi.gamersky.com%2FOAuth%2FQQCallback';

	})
	
	$('.Micro-blogLogin').click(function(){
		location.href = 'https://api.weibo.com/oauth2/authorize?response_type=code&client_id=1585983764&redirect_uri=http%3A%2F%2Fi.gamersky.com%2Foauth%2Fsinacallback';

	})
	
	$('.weChatLogin').click(function(){
		location.href = 'https://open.weixin.qq.com/connect/qrconnect?response_type=code&appid=wx02ddbbcefa377390&scope=snsapi_login&redirect_uri=http%3A%2F%2Fi.gamersky.com%2FOAuth%2FWeixinCallback';

	})

})




		